package src.io;

import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;

public class RafDemo {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException{
		File demo = new File("demo");
		if(!demo.exists())
			demo.mkdir();
		File file = new File(demo,"raf.dat");
		if(!file.exists())
			file.createNewFile();
		
		RandomAccessFile raf = new RandomAccessFile(file, "rw");
		System.out.println(raf.getFilePointer());

		int i = 0x7fffff1f;
//		raf.write(i >>> 24);
//		raf.write(i >>> 16);
//		raf.write(i >>> 8);
//		raf.write(i);
		raf.writeInt(i);
		System.out.println(raf.getFilePointer());
		raf.seek(0);
		byte [] buf=new byte[(int) raf.length()];
		raf.read(buf);
		for (byte b:buf){
			System.out.println(Integer.toHexString(b&0xff));
			System.out.println(Integer.toUnsignedLong(b &0xff));
		}
	    raf.close();
	}
}
